/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}


/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';

	var _com = __webpack_require__(1);

	var _com2 = _interopRequireDefault(_com);

	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

	var components = (0, _com2.default)(['HeaderLayout', 'HeaderDock', 'LayoutMain', 'LayoutBox', 'Btn', 'Icon', 'FormGroup', 'FormInput', 'FormSelect', 'FormUpload', 'FormCode', 'GridRow']);

	//
	new Vue({
		el: '#app',
		components: components,
		created: function created() {
			var _this = this;
			for (var key = 0; key < CATE.length; key++) {
				this.categories.push({
					val: CATE[key].id,
					text: CATE[key].name
				});
			}

			for (var key = 0; key < VAR.length; key++) {
				this.varietiesall.push({
					val: VAR[key].id,
					text: VAR[key].name,
					cid: VAR[key].categoryid
				});
			}
		},
		data: function data() {
			return {
				uploadname: '添加照片',
				categories: [],
				varietiesall: [],
				varieties: []
			};
		},

		methods: {
			submit: function submit() {
				this.$broadcast('form-verify', '');

				if (this.$refs.form.pass) {
					var params = this.$refs.form.data;
					params.image = $('#img').val();

					$.ajax({
						url: SITE_URL + '/admin/save',
						type: 'post',
						data: params,
						success: function success(data) {
							if (!data.code) {
								alert(data.msg);
							} else {
								alert('添加成功');
								window.location.reload();
							}
						},
						error: function error() {
							alert('系统错误');
						}
					});
				} else {
					//this.$refs.myform.setNotice('账号密码不正确')
					console.log('data wrong');
				}
			},
			cateChange: function cateChange(obj) {
				//this.categories = [];
				var vari = [];
				for (var key = 0; key < VAR.length; key++) {
					if (VAR[key].categoryid == obj.val) {
						vari.push({
							val: VAR[key].id,
							text: VAR[key].name
						});
					}
				}
				//console.log(vari.toString());
				this.varieties = vari;
			},
			uploadchange: function uploadchange(file) {
				this.uploadname = '重新添加照片';

				lrz(file.files[0], {
					width: 300
				}).then(function (rst) {
					// 处理成功会执行
					// console.log(rst);
					var img = new Image();
					img.src = rst.base64;

					img.onload = function () {
						document.getElementById('picpreview').innerHTML = '';
						document.getElementById('picpreview').appendChild(img);
					};

					var xhr = new XMLHttpRequest();
					xhr.open('POST', SITE_URL + '/up/up_pic');

					xhr.onload = function () {
						if (xhr.status === 200) {
							//alert(xhr.responseText);
							$('#img').val(xhr.responseText);
						} else {
							alert('网络异常，请重试');
						}
					};

					xhr.onerror = function () {};

					xhr.upload.onprogress = function (e) {
						// 上传进度
						var percentComplete = (e.loaded / e.total || 0) * 100;
					};

					// 添加参数
					rst.formData.append('fileLen', rst.fileLen);
					// rst.formData.append('filedata', rst.file);

					// 触发上传
					xhr.send(rst.formData);

					return rst;
				}).catch(function (err) {
					alert(err);
				}).always(function () {
					// 不管是成功失败，都会执行s
				});
			}
		}
	});

/***/ },
/* 1 */
/***/ function(module, exports) {

	"use strict";

	Object.defineProperty(exports, "__esModule", {
		value: true
	});

	exports.default = function (components) {

		var res = {};
		for (var i = 0; i < components.length; i++) {
			res[components[i]] = Bone[components[i]];
		}
		return res;
	};

/***/ }
/******/ ]);